#include "../include/DictProducer.h"
#include "../include/SplitTool.h"
#include "../include/PageLib.h"
#include "../include/Configuration.h"
#include "../include/DirScanner.h"
#include "../include/FileProcessor.h"
#include "../include/PageLibPreprocessor.h"
#include "../include/WebPageQuery.h"

#include <iostream>

using std::cin;
using std::cout;
using std::endl;

void test0() {
    // Configuration conf("../conf/myconf.conf");
    // Configuration *pconf = &conf;
    // SplitTool splittool;
    // SplitTool *psplittool = &splittool;


    // DictProducer dict1("../source/eng");
    // dict1.buildEnDict();
    // dict1.storeDict("engDict.dat");
    // dict1.createIndex();

    // DictProducer dict2("../source/cn", psplittool);
    // dict2.buildCnDict(pconf);
    // dict2.storeDict("cnDict.dat");
    // dict2.createIndex();

    // DirScanner dirs;
    // FileProcessor filep;
    // PageLib pgl1(pconf, dirs, filep);
    // pgl1.create();
    // pgl1.store();

    // PageLibPreprocessor plpp(pconf, psplittool, pgl1);
    // plpp.doProcess();
    
    WebPageQuery wpq;
    wpq.LoadLibrary();
    wpq.doQuery("国际象棋");
    // wpq.doQuery("黄文秀");
    while (1) {
        string line;
        getline(cin, line);
        timespec startTime;
        timespec endTime;
        clock_gettime(CLOCK_REALTIME, &startTime);
 
        wpq.doQuery(line);
        
        clock_gettime(CLOCK_REALTIME, &endTime);
        std::cout << "耗时：" << endTime.tv_sec - startTime.tv_sec + (endTime.tv_nsec - startTime.tv_nsec) * 0.000000001 << " 秒" << std::endl;
    }
}


int main(void) {
    test0();
    
    return 0;
}
